<?php
declare(strict_types=1);

namespace SixShop\ShippingTemplate\Model;

use SixShop\ShippingTemplate\Enum\ShippingTemplateCalcMethodEnum;
use SixShop\ShippingTemplate\Enum\ShippingTemplateStatusEnum;
use think\Model;
use think\model\concern\SoftDelete;

/**
 * Class SixShop\ShippingTemplate\Model\ShippingTemplateModel
 *
 * @property int $id 主键
 * @property string $name 模板名称
 * @property ShippingTemplateCalcMethodEnum $calc_method 计费方式
 * @property string $unit 单位
 * @property ShippingTemplateStatusEnum $status 状态
 * @property int $sort 排序
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 * @property string $delete_time 删除时间
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 */
class ShippingTemplateModel extends Model
{
    use SoftDelete;

    protected function getOptions(): array
    {
        return [
            'name' => 'shipping_templates',
            'pk' => 'id',
            'type' => [
                'calc_method' => ShippingTemplateCalcMethodEnum::class,
                'status' => ShippingTemplateStatusEnum::class,
            ]
        ];
    }

    public function templateRuleList()
    {
        return $this->hasMany(ShippingTemplateRuleModel::class, 'template_id', 'id');
    }
}